package com.spsy.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spsy.common.log.annotation.Log;
import com.spsy.common.log.enums.BusinessType;
import com.spsy.common.security.annotation.RequiresPermissions;
import com.spsy.system.domain.TShop;
import com.spsy.system.service.ITShopService;
import com.spsy.common.core.web.controller.BaseController;
import com.spsy.common.core.web.domain.AjaxResult;
import com.spsy.common.core.utils.poi.ExcelUtil;
import com.spsy.common.core.web.page.TableDataInfo;

/**
 * 尚品商云Controller
 * 
 * @author spsy
 * @date 2024-10-18
 */
@RestController
@RequestMapping("/shop")
public class TShopController extends BaseController
{
    @Autowired
    private ITShopService tShopService;

    /**
     * 查询尚品商云列表
     */
    @RequiresPermissions("system:shop:list")
    @GetMapping("/list")
    public TableDataInfo list(TShop tShop)
    {
        startPage();
        List<TShop> list = tShopService.selectTShopList(tShop);
        return getDataTable(list);
    }

    /**
     * 导出尚品商云列表
     */
    @RequiresPermissions("system:shop:export")
    @Log(title = "尚品商云", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TShop tShop)
    {
        List<TShop> list = tShopService.selectTShopList(tShop);
        ExcelUtil<TShop> util = new ExcelUtil<TShop>(TShop.class);
        util.exportExcel(response, list, "尚品商云数据");
    }

    /**
     * 获取尚品商云详细信息
     */
    @RequiresPermissions("system:shop:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tShopService.selectTShopById(id));
    }

    /**
     * 新增尚品商云
     */
    @RequiresPermissions("system:shop:add")
    @Log(title = "尚品商云", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TShop tShop)
    {
        return toAjax(tShopService.insertTShop(tShop));
    }

    /**
     * 修改尚品商云
     */
    @RequiresPermissions("system:shop:edit")
    @Log(title = "尚品商云", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TShop tShop)
    {
        return toAjax(tShopService.updateTShop(tShop));
    }

    /**
     * 删除尚品商云
     */
    @RequiresPermissions("system:shop:remove")
    @Log(title = "尚品商云", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tShopService.deleteTShopByIds(ids));
    }
}
